<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="css/login.css">
    <script src="js/jquery-3.5.1.min.js"></script>
    <script src="js/prefix.js"></script>
    <script src="js/welcome.js"></script>
    <script>
        $(function () {
            $("#login").click(function () {
                var username=$("#username").val();
                var password=$("#password").val();
                if(username==""){
                    alert("用户名不能为空！");
                    return;
                }
                if(password==""){
                    alert("密码不能为空！");
                    return;
                }
                var d={
                    "userName":username,
                    "password":password
                };
                $.ajax({
                    url:URL_PREFIX+"/user/login",
                    type:"post",
                    data:JSON.stringify(d),
                    contentType:"application/json",
                    statusCode:{
                        200:function () {
                            alert("登录成功！");
                            window.location="index.html";
                        },404:function () {
                            alert("用户名或密码输入错误！");
                        },500:function () {
                            alert("检测到该设备上已有用户登录，请先退出登录！");
                        },503:function () {
                            alert("服务繁忙，请稍后再试");
                        }
                    }
                })
            })
        })
    </script>
</head>
<body>
<div id="menu"></div>
<div class="menu" style="margin-top: 20px">
    <a href="index.html" class="a"><b><font color="BLACK" size="2">&lt;&lt; 主菜单</font></b></a>
</div>
<div id="stylized" class="myform">
    <form id="form1" name="form1">
        <h1>登录</h1>
        <p>请在此处登录...</p>
        <label>用户名<span class="small">输入你的姓名</span></label>
        <input type="text" name="username" id="username">
        <label>密码<span class="small">输入登录密码</span></label>
        <input type="password" name="password" id="password">
        <button type="button" id="login">登录</button>
        <span>还未注册？<a href="register.html">点此注册</a></span>
        <div class="spacer"></div>
    </form>
</div>
</body>
</html>
